home *** CD-ROM | disk | FTP | other *** search
- Path: morse.ukonline.co.uk!usenet
- From: andy.walsh@ukonline.co.uk
- Newsgroups: comp.lang.c++
- Subject: Re: Dynamically allocating 2-dim arrays
- Date: 9 Apr 1996 14:24:26 GMT
- Organization: UK Online
- Message-ID: <4kdruq$6kg@morse.ukonline.co.uk>
- References: <4k47ii$ppa@galaxy.ucr.edu>
- NNTP-Posting-Host: wwwproxy.ukonline.co.uk
-
- I think if memory serves it is something like this:-
-
- float far* far* image;
-
- image = new float far* [WIDTH];
- for (i=0; i < LENGTH; i++)
- image[i] = new float far [WIDTH];
-
-
- Just replace float with int. With two dimension arrays you have to
- allocate 1D then allocate each of them in a loop (You have to do the
- same for deleting them too):-
-
- for (i=0; i < LENGTH; i++)
- delete[] image[i];
-
- delete[] image;
-
- Hope this helps.
-
- Andy Walsh
-